﻿import requests;

headers ={
# 'Set-Cookie':'c_m_LinID=LinID=WEEvREcwSlJHSldTTEYzVDhUQ05aODlBYThxQ3NxZXkrQ2YvMnM0UzJQQT0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4IQMovwHtwkF4VYPoHbKxJw!!&ot=06/13/2021 19:39:52; domain=cnki.net; expires=Sun, 13-Jun-2021 11:39:52 GMT; path=/',
# 'Set-Cookie':'LID=WEEvREcwSlJHSldTTEYzVDhUQ05aODlBYThxQ3NxZXkrQ2YvMnM0UzJQQT0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4IQMovwHtwkF4VYPoHbKxJw!!; domain=cnki.net; expires=Sun, 13-Jun-2021 11:39:52 GMT; path=/',
# 'Set-Cookie':'c_m_expire=2021-06-13 19:39:52; domain=cnki.net; expires=Sun, 13-Jun-2021 11:39:52 GMT; path=/',
'Set-Cookie':'Ecp_LoginStuts={"IsAutoLogin":false,"UserName":"13521675173","ShowName":"13521675173","UserType":"jf","BUserName":"","BShowName":"","BUserType":"","r":"c7GV0y"}; domain=cnki.net; expires=Sun, 13-Jun-2021 11:39:52 GMT; path=/',
# 'Set-Cookie':'LID=WEEvREcwSlJHSldTTEYzVDhUQ05aODlBYThxQ3NxZXkrQ2YvMnM0UzJQQT0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4IQMovwHtwkF4VYPoHbKxJw!!; domain=cnki.net; path=/'
}
# headers ={
# 'Set-Cookie':['LID=WEEvREcwSlJHSldTTEYzVDhUQ05aODlBYU0wZ3hYQVZTZ215R0hQNlNxbz0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4IQMovwHtwkF4VYPoHbKxJw!!; domain=cnki.net; expires=Sun, 13-Jun-2021 12:24:02 GMT; path=/','c_m_LinID=LinID=WEEvREcwSlJHSldTTEYzVDhUQ05aODlBYU0wZ3hYQVZTZ215R0hQNlNxbz0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4IQMovwHtwkF4VYPoHbKxJw!!&ot=06/13/2021 20:24:02; domain=cnki.net; expires=Sun, 13-Jun-2021 12:24:02 GMT; path=/','c_m_expire=2021-06-13 20:24:02; domain=cnki.net; expires=Sun, 13-Jun-2021 12:24:02 GMT; path=/','Ecp_LoginStuts={"IsAutoLogin":false,"UserName":"13521675173","ShowName":"13521675173","UserType":"jf","BUserName":"","BShowName":"","BUserType":"","r":"aoG0gS"}; domain=cnki.net; expires=Sun, 13-Jun-2021 12:24:02 GMT; path=/']
# }


print(headers)

s = requests.Session()
for i in range(8,72):
    url = 'https://kreader.cnki.net/Kreader/OpenFile.ashx?dbCode=cdmd&doc=1011232445.nh&tabelName=CMFD2012&format=png&uid=&page='+str(i)+'&mpc=71&v=MjQwODdYYXhHQ2FJYm9RMWJMcWJNMzVBPT1CZ25tU3YvTFk2ZTRyWTlFWnFjT0RIMDR6UlVSN2p0NFZpRzY0QkExZTdPTFE2V2VaUFp1SGlQaFZMVExJekE='

    r = s.post(
        url,
        headers = headers
        )

    # print(r.content)

    fo = open(str(i)+'.png', 'wb')

    fo.write(r.content)

    fo.close()

    print(str(i))

